    const nameInp = document.querySelector('#username')
    const pwdInp = document.querySelector('#password')
    const btn = document.querySelector('#button')

    btn.onclick = function () {
      const name = nameInp.value
      const pwd = pwdInp.value

      if (!name || !pwd) return

      const data = `username=${ name }&password=${ pwd }`


      // 发送请求
      const xhr = new XMLHttpRequest()

      xhr.open('POST', '../server/login.php')

      xhr.onload = function () {
        const res = JSON.parse(xhr.responseText)
        console.log(res)
      }

      // 请求头
      xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded')

      xhr.send(data)
    }